package com.jingdianjichi.handler;

import com.jingdianjichi.util.WxUtil;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * 订阅事件处理器
 */
@Component
public class SubscribeHandler implements CallBackTypeHandler {
    
    @Override
    public String handle(Map<String, String> messageMap) {
        String fromUserName = messageMap.get("FromUserName");
        String toUserName = messageMap.get("ToUserName");
        
        // 构建回复消息
        Map<String, String> replyMap = new HashMap<>();
        replyMap.put("ToUserName", fromUserName); // 回复给发送者
        replyMap.put("FromUserName", toUserName); // 来自公众号
        replyMap.put("CreateTime", String.valueOf(System.currentTimeMillis() / 1000));
        replyMap.put("MsgType", "text");
        replyMap.put("Content", "谢谢关注");
        
        return WxUtil.buildWeChatXml(replyMap);
    }
}
